package com.example.makerspace.aop;

import com.example.makerspace.dto.Result;
import com.example.makerspace.enums.ResultCodeEnum;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.multipart.MultipartException;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = MultipartException.class)
    @ResponseBody
    public Result handleBusinessException(MaxUploadSizeExceededException ex) {
        return Result.error(ResultCodeEnum.FILE_SIZE_EXCEED);
    }
}
